package cn.com.zcode.core.model;

import java.util.ArrayList;
import java.util.List;

public class Page<M> {

	private int current; 

	private int size; 

	private int totalNum; 

	private List<M> datas = new ArrayList<M>();
	 

	public int getFirstIndex() {
		return size * (current - 1);
	}

	public boolean hasPrevious() {
		return current > 1;
	}

	public boolean hasNext() {
		return current < getTotalPage();
	}

	public int getTotalPage() {
		if (totalNum % size ==0) {
			return totalNum / size;
		}
		return totalNum / size + 1;
	}

	public int getCurrent() {
		return current;
	}

	public void setCurrent(int current) {
		this.current = current;
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	public int getTotalNum() {
		return totalNum;
	}

	public void setTotalNum(int totalNum) {
		this.totalNum = totalNum;
	}

	public List<M> getDatas() {
		return datas;
	}

	public void setDatas(List<M> datas) {
		this.datas = datas;
	}
	

}
